import java.util.Scanner;

public class Calculator {
    double numberA;
    double numberB;
    public double add(){
        return  numberA +numberB;
    }
    public double sub(){
        return  numberA-numberB;

    }
    public double mul(){
        return  numberA*numberB;
    }
    public  double div() {
        if (numberB == 0) {
            System.out.println("除数不能为0");
           return 0;
        }
        else {
            return numberA / numberB;
        }
    }
    public void showCalculator(){
        System.out.print("加法："+this.add()+"\n减法："+this.sub()+"\n乘法："
                +this.mul()+"\n除法：");this.div();
    }

    public static void main(String[] args) {
        Calculator calculator = new Calculator();
        Scanner input = new Scanner(System.in);
        double result = 0.0;
        System.out.println("请输入第一个操作数：");
        double numberA = input.nextDouble();
        System.out.println("请输入运算符(+、-、*、/):");
        char ch=input.next().charAt(0);
        System.out.println("请输入第二个操作数：");
        double numberB = input.nextDouble();
        switch (ch){
            case '+':
                calculator.add();
                break;
            case '-':
                calculator.sub();
                break;
            case '*':
                calculator.mul();
                break;
            case '/':
               calculator.div();
                break;
            default:
                System.out.println("你输入的运算符不正确!");
        }
        System.out.println("得"+result);
    }



}

